<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>rsa登录</title>
    <script  type="text/javascript" src="/static/jquery-1.9.1.min.js"></script>
    <script  type="text/javascript" src="/static/security.js"></script>
</head>
<body>
未做处理，别使用中文，否则后台解密乱码
<input id="rsa" th:value="${rsa}" type="hidden"/>
<div>
账号: <input id="loginName" />
</div>
<div>
密码: <input id="password" />
</div>
<div>
    <button id="submitBtn" type="button">登录</button>
</div>
</body>
<script type="text/javascript">
$(function(){
    var rsa = JSON.parse($("#rsa").val());
    var modulus = rsa.modulus;// 系数
    var exponent = rsa.exponent;// 指数
    var publicKey = '';// 公钥
    if (modulus == '' || exponent == '') {
        console.error('modules=' + modules + ', exponent=' + exponent + ' is null')
    }
    publicKey = RSAUtils.getKeyPair(exponent, '', modulus);

    $("#submitBtn").on("click",function () {
        var dataParam = {};
        dataParam.loginName = $("#loginName").val();
        dataParam.password = $("#password").val();
        for (var index in dataParam) {
            dataParam[index] = RSAUtils.encryptedString(publicKey, dataParam[index])
        }
        $.ajax({
            type: "POST",
            async: false,
            url: "/login",
            data: dataParam,
            success: function(data, status) {
            }
        });
    });



});
</script>
</html>